package org.cuatrovientos.empirefleet;

import java.util.Scanner;
import java.util.Vector;

/**
 * Represents an imperial fleet composed
 * of many space_ships
 * @author Sienar Fleet Systems
 * @greets the emperor
 */
public class Fleet extends Vector<SpaceShip> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	String commanderName;
	
	/**
	 * creates fleet
	 * three steps: define commander name, create fleet, show fleet
	 */
	public void createFleet () {
		Scanner scanner = new Scanner(System.in);
		String option = "";
		String name = "";
		
		// Give commander name
		do {
			System.out.println("Identify yourself");
			commanderName = scanner.nextLine();
		} while (commanderName.isEmpty());
		
		// We start a loop to define the fleet
		// In each loop commander chooses one kind of ship to be added
		// to his fleet
		do {
			System.out.println("What kind of ship do you want?");
			System.out.println("1.TF \n 2.TA \n 3.TB \n 4.Exit\n");
			option = scanner.nextLine();
			
			switch (option) {
				case "1": // a tie fighter
						System.out.println("Name of the pilot: "); 
						name = scanner.nextLine();
						this.add(new TieFighter(name));
						break;
				case "2":
						System.out.println("Name of the pilot: "); 
						name = scanner.nextLine();
						this.add(new TieAdvanced(name));
						break;
				case "3":
						System.out.println("Name of the pilot: "); 
						name = scanner.nextLine();
						this.add(new TieBomber(name));
						break;
				case "4":
						System.out.println("Ended.");
						break;
				default:
						System.out.println("Option incorrect");
			}
		} while(!option.equals("4"));
		
		// Resume: show complete fleet info
		// using foreach like for
		for (SpaceShip ship : this) {
			System.out.println("Type: " + ship.type + "," + ship.toString());
		}
	}
}
